Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(browser): resolve pretty-format in yarn #3660

Closed
wants to merge 1 commit into from

Conversation

AriPerkkio
Copy link
Member

Minimal reproduction

git clone https://github.com/AriPerkkio/aria-live-capture.git
cd aria-live-capture
git checkout 27031730f0bfa51e66c25900f380580c95b0a17c

# Switch to yarn
rm -rf node_modules/ pnpm-lock.yaml
yarn install
yarn test
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Error ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
ReferenceError: exports is not defined
 ❯ http:/localhost:63315/node_modules/@vitest/utils/node_modules/pretty-format/build/index.js?v=5c8adf77:3:23
# Apply PR's fix:
# Add "pretty-format" to line 1944
code node_modules/@vitest/browser/dist/index.js

# Success
yarn test

However pnpm with hoist=false is still broken:

git clone https://github.com/AriPerkkio/aria-live-capture.git
cd aria-live-capture
git checkout 27031730f0bfa51e66c25900f380580c95b0a17c
echo "hoist=false" >> .npmrc
pnpm i
pnpm test
ReferenceError: exports is not defined
 ❯ http:/localhost:63315/node_modules/.pnpm/[email protected]/node_modules/pretty-format/build/index.js?v=a19edd20:3:23

@AriPerkkio AriPerkkio requested a review from userquin June 25, 2023 07:59
@stackblitz
Copy link

stackblitz bot commented Jun 25, 2023

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@userquin
Copy link
Member

userquin commented Jun 25, 2023

pnpm + hoist=false will not work since @vitest/utils is not a dependency of the browser package. You must install @vitest/utils to make it working.

Once @vitest/utils installed, it will not work, you also need to add the following entries to optimizedDeps.include:

"@vitest/utils > diff-sequences",
"@vitest/utils > loupe",
"@vitest/utils > pretty-format",
"@vitest/utils > pretty-format > ansi-styles",
"@vitest/utils > pretty-format > ansi-regex",
"@vitest/utils > chai"

We need to test it in pnpm and yarn, we can add all the combinations:

"vitest > diff-sequences",
"vitest > loupe",
"vitest > pretty-format",
"vitest > pretty-format > ansi-styles",
"vitest > pretty-format > ansi-regex",
"vitest > chai",
"@vitest/utils > diff-sequences",
"@vitest/utils > loupe",
"@vitest/utils > pretty-format",
"@vitest/utils > pretty-format > ansi-styles",
"@vitest/utils > pretty-format > ansi-regex",
"@vitest/utils > chai",
"diff-sequences",
"loupe",
"pretty-format",
"pretty-format > ansi-styles",
"pretty-format > ansi-regex",
"chai"

@sheremet-va
Copy link
Member

Let's just inline pretty-format and diff-sequence (for pretty format we need to update imports in vitest)

@AriPerkkio AriPerkkio closed this Jun 26, 2023
@AriPerkkio AriPerkkio deleted the fix/browser-mode-yarn branch June 26, 2023 05:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Vitest fails to run with browser mode, displaying a blank screen
3 participants